home *** CD-ROM | disk | FTP | other *** search
- /* tzset.c Turbo C Bible Functions, p. 339 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- extern char *tzname[2];
- main()
- {
- time_t tnow;
- if(putenv("TZ=EST5EDT")== -1)
- /* Set the envirnoment variable TZ to Eastern Standard
- * Time with daylight saving enabled. See text for
- * information on defining TZ. */
- {
- printf("Error defining TZ\n");
- exit(1);
- }
- /* Now call "tzset" to set up internal global variables */
- tzset();
- /* Print the current values of the global variables*/
- printf("timezone = %ld, daylight = %d, \n"
- "tzname[0] = %s\ntzname[1] = %s\n", timezone, daylight,
- tzname[0], tzname[1]);
- /* Get and display current local time -- should be EDT */
- time(&tnow);
- printf("Local time = %s", ctime(&tnow));
- }